/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server;

import DAL.DAL;
import client.Client;
import java.net.ServerSocket;
import java.net.Socket;

/**
 *
 * @author Mr Bao
 */
public class Server implements Runnable {

    private ServerSocket serverSocket;
    private Socket socket;
    private DAL d;

    public Server() {
        try {
            serverSocket = new ServerSocket(1234);
            d = new DAL();
            new Thread(this).start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void run() {
        while (true) {
            try {
                socket = serverSocket.accept();
                System.out.println("connect");
                new Client(socket, d);
                System.gc();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
